onmessage = function(eve) {
	var fun = eve.data[0];
	switch(fun) {
		case 'initTime':
			initTime();
			break;
		case 'checkTime':
			checkTime();
			break;
		case 'continuedTime':
			continuedTime(eve.data[1],eve.data[2]);
			break;
	}
}

function initTime() {
	var startTime = new Date(),
		times = {};
	times.year = startTime.getFullYear();
	times.mon = startTime.getMonth() + 1;
	times.date = startTime.getDate();
	times.hour = startTime.getHours();
	times.min = startTime.getMinutes();
	times.sec = startTime.getSeconds();
	postMessage(times);
}

function checkTime() {
	var nowTime = new Date(),
		times = {};
	times.hour = nowTime.getHours();
	times.min = nowTime.getMinutes();
	times.sec = nowTime.getSeconds();
	postMessage(times);
}

function continuedTime(star,now) {
	var times = {};
	times.hour = now.hour - star.hour;
	times.min = now.min - star.min;
	times.sec = now.sec - star.sec;
	postMessage(times);
}